/**
 * Created by JetBrains WebStorm.
 * User: dimas
 * Date: 16.09.11
 * Time: 23:18
 * To change this template use File | Settings | File Templates.
 */
function MapClass(mapDom, option, cells){
    var def = {cols:15, rows:15};
    var options = expandOptions(def, option);

    this.mapDom = mapDom;
    this.cells = cells || [];
    this.cols = options.cols;
    this.rows = options.rows;

    /**
     * return map size
     * (cols * rows)
     */
    this.mapSize = function(){ return this.cols * this.rows; }

    /**
     * expand options
     * @param def
     * @param obj
     */
    function expandOptions(def, obj){
        var res = def;
        if(obj){
            if(obj.cols) def.cols = obj.cols;
            if(obj.rows) def.rows = obj.rows;
        }
        return res;
    }

    /**
     * get cell
     * @param x - col number
     * @param y - row number
     */
    this.getCell = function(x,y){
        return (this.cells[x]) ? this.cells[x][y] : null;
    }
}